import axios from 'axios';
import loading from './loading';

// post请求数据
function post(url, data, cb, isload = false) {
    if (isload) {loading.load()}
    axios.post(url, data).then(function (res) {
        if (isload) {loading.close()}
        if (res.data.code != 0) {
            return cb(res.data.code, res.data.msg, {})
        }
        return cb(0, 'success', res.data.data)
    }).catch((error) => {
        if (isload) {loading.close()}
        return cb(9999, '异常错误', {})
    });
}

export default {
    post
}
